﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ToDoClear
{
    public static class FpsDetect
    {
        private const string TAG = "FpsDetect";
        static DateTime oldTime=DateTime.Now.AddDays(-1);
        static DateTime newTime = DateTime.Now.AddDays(-1);
        static int frames = 0;
        static double allTime = 0.0;

        public static void Update()
        {
            newTime = DateTime.Now;
            double dtime=(newTime - oldTime).TotalMilliseconds;
            if (dtime > 1000)
            {
                frames = 0;
                allTime=0;
            }
            else
            {
                frames++;
                allTime += dtime;
                if (frames > 10)
                {
                    double fps = frames / allTime*1000;
                    Log.d(TAG, "fps:" + fps);
                    frames = 0;
                    allTime = 0;
                }
            }
            oldTime = DateTime.Now;
           
        }

    }
}
